Skip to main content

Stable VLP

Query Messages

note

We will only go through the queries for this contract, as users are not allowed to execute any messages on the Stable VLP contract directly. You can read about the Stable VLP architecture here.

List of queries that can be performed on the Stable VLP contract.

State

Queries the full state of the Stable VLP contract.

pub enum QueryMsg {
    #[returns(GetStateResponse)]
    State {},
}
{"state":{}}

The query returns the following response:

pub struct GetStateResponse {
pub pair: Pair,
pub router: String,
pub virtual_balance: String,
pub fee: Fee,
pub total_fees_collected: TotalFees,
pub last_updated: u64,
pub total_lp_tokens: Uint128,
pub admin: String,
pub pool_config: PoolConfig,
}

With the following stucts:

TotalFees

pub struct TotalFees {
// Fee for lp providers
pub lp_fees: DenomFees,
// Fee for euclid treasury, distributed among stakers and other euclid related rewards
pub euclid_fees: DenomFees,
}

pub struct DenomFees {
// A map to store the total fees per denomination
pub totals: HashMap<String, Uint128>,
}

PoolConfig

Defines the configuration type for a liquidity pool. It can either be a Stable Pool (with an optional amplification factor) or a Constant Product Pool (normal XYK pool).

pub enum PoolConfig {
Stable { amp_factor: Option<Uint64> },
ConstantProduct {},
}
FieldTypeDescription
pairPairThe token pair in the Stable VLP.
routerStringThe address of the Router contract.
virtual_balanceStringThe address of the Virtual Balance contract.
feeFeeThe fee structure applied to the pool.
total_fees_collectedTotalFeesTotal fees collected by the pool.
last_updatedu64Last timestamp the pool state was updated.
total_lp_tokensUint128Total LP tokens issued.
adminStringAdmin address managing the contract.
pool_configPoolConfigConfiguration of the pool (stable, amp factor, etc.).

SimulateSwap

Simulates a swap within the Stable VLP.

pub enum QueryMsg {
    #[returns(GetSwapResponse)]
    SimulateSwap {
        asset: Token,
        asset_amount: Uint128,
        swaps: Vec<NextSwapVlp>,
    },
}
{
  "simulate_swap": {
    "asset": "usdc",
    "asset_amount": "1000000",
    "swaps": [
      { "vlp_address": "nibi1..." }
    ]
  }
}
FieldTypeDescription
assetTokenThe input token for the swap simulation.
asset_amountUint128The amount of the asset being swapped.
swapsVec<NextSwapVlp>The swap path across multiple VLPs.

The query returns the following response:

pub struct GetSwapResponse {
pub amount_out: Uint128,
pub asset_out: Token,
pub spread_amount: Uint128,
}
FieldTypeDescription
amount_outUint128The expected output amount from the swap.
asset_outTokenThe token received after the swap.
spread_amountUint128The amount lost due to spread (difference from ideal price).

Liquidity

Queries the total liquidity reserves for the Stable VLP.

pub enum QueryMsg {
    #[returns(GetLiquidityResponse)]
    Liquidity {},
}
{
  "liquidity": {}
}

The query returns the following response:

pub struct GetLiquidityResponse {
pub pair: Pair,
pub token_1_reserve: Uint128,
pub token_2_reserve: Uint128,
pub total_lp_tokens: Uint128,
}
FieldTypeDescription
pairPairThe token pair involved in the liquidity. The token Id for each token is returned.
token_1_reserveUint128Reserve amount for token 1.
token_2_reserveUint128Reserve amount for token 2.
total_lp_tokensUint128The total amount of liquidity pool tokens. These tokens are given to a user whenever they add liquidity to a pool and can be returned to the VLP to withdraw the added liquidity later on.

Fee

Queries the fee distribution configuration for the Stable VLP.

pub enum QueryMsg {
    #[returns(FeeResponse)]
    Fee {},
}
{"fee":{}}

The query returns the following response:

pub struct FeeResponse {
pub fee: Fee,
}

With the following Fee struct:

pub struct Fee {
pub lp_fee_bps: u64,
pub euclid_fee_bps: u64,
pub recipient: CrossChainUser,
}

NameTypeDescription
lp_fee_bpsu64Fee for liquidity providers, in basis points. Can be set to a maximum of 10%.
euclid_fee_bpsu64Fee for Euclid treasury, distributed among stakers and other Euclid-related rewards, in basis points e. 1 = 0.01% 10000 = 100%. Can be set to a maximum of 3%.
recipientCrossChainUserThe recipient for the fee. Can be an address on any chain.

TotalFeesCollected

Queries the total fees collected across all operations.

pub enum QueryMsg {
    #[returns(TotalFeesResponse)]
    TotalFeesCollected {},
}
{
  "total_fees_collected": {}
}

The query returns:

pub struct TotalFeesResponse {
pub total_fees: TotalFees,
}
FieldTypeDescription
total_feesTotalFeesAggregated fees for LPs and protocol.
pub struct TotalFees {
// Fee for lp providers
pub lp_fees: DenomFees,
// Fee for euclid treasury, distributed among stakers and other euclid related rewards
pub euclid_fees: DenomFees,
}

pub struct DenomFees {
// A map to store the total fees per denomination
pub totals: HashMap<String, Uint128>,
}

TotalFeesPerDenom

Queries the total fees collected for a specific token denom.

pub enum QueryMsg {
    #[returns(TotalFeesPerDenomResponse)]
    TotalFeesPerDenom { denom: String },
}
{
  "total_fees_per_denom": {
    "denom": "usdc"
  }
}
FieldTypeDescription
denomStringThe token denomination to query for.

The query returns:

pub struct TotalFeesPerDenomResponse {
pub lp_fees: Uint128,
pub euclid_fees: Uint128,
}
FieldTypeDescription
lp_feesUint128Total fees collected for liquidity providers.
euclid_feesUint128Total fees collected for Euclid Treasury.

Pool

Queries pool-specific info for a particular chain.

pub enum QueryMsg {
    #[returns(StablePoolResponse)]
    Pool { chain_uid: ChainUid },
}
{
  "pool": {
    "chain_uid": "injective"
  }
}

The query returns:

pub struct StablePoolResponse {
pub lp_shares: Uint128,
pub reserve_1: Uint128,
pub reserve_2: Uint128,
}
FieldTypeDescription
lp_sharesUint128The total amount of liquidity pool shares.
reserve_1Uint128The total reserve amount of the first token.
reserve_2Uint128The total reserve amount of the second token.

GetAllPools

Queries all pools across all chains.

pub enum QueryMsg {
    #[returns(AllStablePoolsResponse)]
    GetAllPools {},
}
{
  "get_all_pools": {}
}

The query returns:

pub struct AllStablePoolsResponse {
pub pools: Vec<StablePoolInfo>,
}

pub struct StablePoolInfo {
pub chain_uid: ChainUid,
pub pool: StablePoolResponse,
}

NameTypeDescription
chain_uidChainUidThe unique Id of the chain where the pool is deployed.
poolStablePoolResponseThe information on the pool. Same as the struct returned by the Pool query.